package service

import (
	"github.com/dchest/captcha"
	"github.com/gin-gonic/gin"
)

type GraphiCaptcha struct {
	Base
}

func (s GraphiCaptcha) Create(c *gin.Context) map[string]string {

	length := captcha.DefaultLen
	captchaId := captcha.NewLen(length)

	captcha := make(map[string]string)
	captcha["captcha_id"] = captchaId
	captcha["captcha_url"] = "/share/captcha/" + captchaId + ".png"
	return captcha
}

func (s GraphiCaptcha) Verify(captchaId string, val string, c *gin.Context) bool {
	return captcha.VerifyString(captchaId, val)
}
